Skip to content

[WC-3630] Gallery: fix refresh interval having no effect - #2487

Open
yordan-st wants to merge 2 commits into
mainfrom
fix/WC-3630_gallery-refresh-interval
Open

yordan-st wants to merge 2 commits into
mainfrom
fix/WC-3630_gallery-refresh-interval

Conversation

@yordan-st

@yordan-st yordan-st commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

Gallery's "Refresh time (in seconds)" property has had no effect since the DI container migration (b5010ee). galleryConfig hard-coded refreshIntervalMs: 0, and the GY.refreshInterval token injected into DatasourceService was never bound.

  • Derives refreshIntervalMs from props.refreshInterval * 1000 and binds GY.refreshInterval in the query bindings, mirroring Datagrid 2.
  • Container-level regression tests with fake timers: the data source reloads at 5 s when the interval is 5, and never when it is 0. The tests fail without the fix.
  • No XML change, so no docs update is needed.

Found while implementing WC-3362.

What should be covered while testing?

  • Gallery with Refresh time = 5: change data in another tab, Gallery updates within ~5 s
  • Refresh time = 0: no automatic update
  • With Refresh indicator on and an interval above 1 s, the silent-refresh indicator shows during the background reload
  • No errors in the DevTools console

@yordan-st yordan-st changed the title [WC-3630]: Fix Gallery refresh interval having no effect [WC-3630] Gallery: fix refresh interval having no effect Oct 22, 2026
@yordan-st
yordan-st marked this pull request as ready for review October 22, 2026 09:09
@yordan-st
yordan-st requested a review from a team as a code owner October 22, 2026 09:09
@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3630_gallery-refresh-interval branch from e1a15bd to 44bffda Compare October 22, 2026 09:25
@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3630_gallery-refresh-interval branch from 44bffda to dce857b Compare October 22, 2026 09:50
@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3630_gallery-refresh-interval branch from dce857b to eb307a8 Compare October 23, 2026 10:58
The DI container migration hard-coded refreshIntervalMs to 0 and never bound
GY.refreshInterval, so the Refresh time property had no effect. Derive the interval
from props and bind the token, mirroring Datagrid. Adds container-level regression tests.

Ticket: WC-3630
@yordan-st
yordan-st force-pushed the fix/WC-3630_gallery-refresh-interval branch from eb307a8 to d41ba90 Compare October 27, 2026 09:21
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
packages/pluggableWidgets/gallery-web/src/model/configs/Gallery.config.ts Derives refreshIntervalMs from props.refreshInterval * 1000 instead of hard-coded 0
packages/pluggableWidgets/gallery-web/src/model/containers/Gallery.container.ts Binds GY.refreshInterval token in _02_queryBindings.init
packages/pluggableWidgets/gallery-web/src/model/containers/__tests__/createGalleryContainer.spec.ts Adds three new container-level regression tests with fake timers
packages/pluggableWidgets/gallery-web/CHANGELOG.md Adds "Fixed" entry under [Unreleased]
packages/pluggableWidgets/gallery-web/openspec/changes/fix-refresh-interval-wiring/* OpenSpec change artifacts (proposal, design, spec, tasks)

Skipped (out of scope): dist/, pnpm-lock.yaml

CI checks: could not retrieve (permission denied) — author confirms lint and tests pass locally (tasks.md §3.2 ✓).


Findings

⚠️ Low — Existing test assertion refreshIntervalMs: 0 will silently pass for the wrong reason

File: src/model/containers/__tests__/createGalleryContainer.spec.ts line 59–63
Note: The pre-existing test "bind gallery config to the container" checks refreshIntervalMs: 0. After this fix that expectation still passes only because mockContainerProps() defaults refreshInterval: 0, which now correctly produces 0 * 1000 = 0. That means the assertion was true before (hard-coded 0) and remains true after (computed 0) — it doesn't prove the new derivation logic is exercised. The new dedicated test at line 66–71 covers this properly, but the old assertion is misleading; it reads as "the default is 0 because it should be" rather than "because 0 × 1000 = 0". Consider updating the comment or toMatchObject to make the intent clear, e.g. add a comment // refreshInterval default is 0, so ms is also 0.


⚠️ Low — showSilentRefresh threshold inconsistency not tracked

File: src/model/containers/Gallery.container.ts line 161
Note: The design doc notes that showSilentRefresh uses props.refreshInterval > 1 (exclusive), whereas the pre-migration code used >= 1 (inclusive). The change intentionally leaves this as-is ("separate, cosmetic difference"), but there is no follow-up ticket or TODO comment in the code. A user setting refreshInterval = 1 will have periodic refresh working (fixed by this PR) but no silent-refresh indicator (off-by-one vs. the original behaviour). Low severity since the design doc calls it out — just worth a TODO or a linked ticket to avoid the inconsistency being forgotten.


Positives

  • The two-line fix is minimal and exactly mirrors how Datagrid 2 wires the same token — easy to verify correctness by inspection.
  • Fake-timer tests cover both the positive case (reload fires at exactly 5000 ms, not 4999 ms) and the negative case (no reload for 60 s at interval 0), giving strong confidence the full DI path is exercised.
  • The existing refreshInterval: 0 default in mockContainerProps means the rest of the test suite was already exercising the "no refresh" path implicitly, so no accidental regressions were introduced.
  • OpenSpec artifacts (proposal, design, spec, tasks) are thorough and correctly scoped to the widget package.
  • CHANGELOG entry is user-facing and describes the symptom, not the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants